<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}text.css" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}enhanced.css" />
<link rel="stylesheet" href="${aier_css_url}school/ma.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>

<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}custominput.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}text.js"></script>
<title>菜谱管理</title>

<script type="text/javascript">

$(document).ready(function(){          
	$("#caipuinfo").jqGrid({                
		url:'${aier_url}${aier_urijs}caipu_search${aier_suffix}?cp_time=0',                
		datatype:"json",                
		mtype:'GET', 
		height:'280',
		width:'1150',                 
		colNames:['名称','板块','工艺','难度','口味','人数(份)','准备时长(分)','烹饪时长(分)','主料','辅料','主图','操作','id','主图名'],                
		colModel:[                    
		{name:'cp_name',index:'cp_name',width:100,align:'center', sortable:false},                    
		{name:'cx_name',index:'cx_name',width:100,align:'center', sortable:false},    
		{name:'gy_name',index:'gy_name',width:60,align:'center', sortable:false},                  
		{name:'nd_name',index:'nd_name',width:80,align:'center', sortable:false},
		{name:'kw_name',index:'kw_name',width:80,align:'center', sortable:false},
		{name:'cp_number',index:'cp_number',width:60,align:'center'},
		{name:'cp_ptime',index:'cp_ptime',width:90,align:'center'},
		{name:'cp_time',index:'cp_time',width:90,align:'center'},
		{name:'zl_names',index:'zl_names',width:160,align:'center', sortable:false},
		{name:'fl_names',index:'fl_names',width:240,align:'center', sortable:false},
		{name:'img',index:'cp_img',width:80,align:'center', sortable:false},
		{name:'option',index:'cp_id',width:80,align:'center', sortable:false},
		{name:'cp_img',index:'cp_img',hidden:true},
		{name:'cp_id',index:'cp_id',hidden:true}
		],
		//autowidth:true,
		jsonReader: {
			root:"caipuList",
			page: "page",
			total: "page_count",
			records : "count",
			repeatitems: false
		},
		pager: jQuery("#caipupage"),
		prmNames : {page:"page"},
		rowNum: 10,
		//rowList: [10, 20, 30],
		sortname: 'cp_time',
		hidegrid: false,
		sortorder: 'asc',
		viewrecords: true,
		caption: '菜谱信息',
		gridComplete:function(){
			var ids=jQuery("#caipuinfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i];   
				up = "<a href='javascript:;' class='jqtrow' onclick='update(" + id + ")'>修改</a>";
				del = "<a href='javascript:;' class='jqtrow' onclick='delTel(" + id + ")'>删除</a>";
				ifo = up + " " + del;
				var imgName = jQuery("#caipuinfo").jqGrid('getRowData', id).cp_img;
				if(imgName!=null&&imgName!=""){
					var img_url = "${imgUrl}"+imgName;
					imginfo = "<a href='"+img_url+"' class='jqtrow' target='_blank'><img src='"+img_url+"' height='20px' width='30px'></a>";				
				}else{
					imginfo = "";
				}

				jQuery("#caipuinfo").jqGrid('setRowData', ids[i], {option:ifo,img:imginfo});
			}
		}
	}).navGrid("#caipupage", { edit: false, add: false, del: false, search: false });
});

function delTel(id){
	 $("#deltname").html(jQuery("#caipuinfo").jqGrid('getRowData', id).cp_name);
	 $(function() {
			$( "#caipu_del" ).dialog({
				modal: true,
				resizable: false,
				buttons: {
					"删除": function() {
						var funadd = function(data1){
							if(1==data1.s){
								 $().message("删除成功!");
								 $("#caipuinfo").trigger("reloadGrid");
								 $("#caipu_del").dialog( "close" );
							}else{
								 $().message("删除失败!");
							}
						};
						exeAjax(ajaxUrl("${aier_url}${aier_urijs}caipu_delete${aier_suffix}"), funadd, {"cp_id_del" :jQuery("#caipuinfo").jqGrid('getRowData', id).cp_id});
					},"取消": function() {
						$( this ).dialog( "close" );
					}
				}
			});
		});
}

function update(id){
	window.location.href="${aier_url}${aier_uri}caipu_update${aier_suffix}?cp_id_del="+jQuery("#caipuinfo").jqGrid('getRowData', id).cp_id;
}
		
function add(){
	window.location.href="${aier_url}${aier_uri}caipu_add${aier_suffix}";
}

</script>
</head>
<body>

				<div id="tabs">
					<ul>
						<li><a href="#tabs-1">hi菜谱信息</a>
						</li>
					</ul>
					<div id="tabs-1" style="height: 500px;">
						<div class="d_content">
							<div>
								<div class="d_scnOut">
									<div class="d_scname">
										<label for="start_txt">工艺:</label>
									</div>
									<div class="sel_position">
										<select id="gy_types">
											<option value="-1">请选择</option>
											<c:forEach  var="gy" items="${gongyiList }">
												<option value="${gy.gy_id}">${gy.gy_name}</option>
											</c:forEach>
										</select>
									</div>
								</div>
								<div class="d_scnOut">
									<div class="d_scname">
										<label for="txt_tName">口味:</label>
									</div>
									<div class="sel_position">
										<select id="kw_types">
											<option value="-1">请选择</option>
											<c:forEach  var="kw" items="${kouweiList }">
												<option value="${kw.kw_id}">${kw.kw_name}</option>
											</c:forEach>
										</select>
									</div>
								</div>
							</div>
							<div style="margin-top: -80px;margin-left: 250px;">
								<div class="d_scnOut">
									<div class="d_scname">
										<label for="end_txt">难度:</label>
									</div>
									<div class="sel_position">
										<select id="nd_types">
											<option value="-1">请选择</option>
											<c:forEach  var="nd" items="${nanduList }">
												<option value="${nd.nd_id}">${nd.nd_name}</option>
											</c:forEach>
										</select>
									</div>
								</div>
								<div class="d_scnOut">
									<div class="d_scname">
										<label for="sel_">板块:</label>
									</div>
									<div id="tm2008style" class="sel_position">
										<select id="cx_types">
											<option value="-1">请选择</option>
											<c:forEach  var="cx" items="${caixiList }">
												<option value="${cx.cx_id}">${cx.cx_name}</option>
											</c:forEach>
										</select>
									</div>
								</div>
							</div>
							<div style="margin-top: -80px;margin-left: 500px;">
								<div class="d_scnOut">
									<div class="d_scname">
										<label for="end_txt">名称:</label>
									</div>
									<div class="d_sctext">
										<input id="cp_name" type="text">
									</div>
								</div>
								<div class="d_scnOut">
									<div class="d_scname">
										<!-- <label for="sel_">小于时长:</label> -->
									</div>
									<div id="tm2008style" class="d_sctext">
										<input id="cp_time" type="text" hidden="hidden">
									</div>
								</div>
							</div>
							<button onclick="search()" 
								style="margin-top: 0px;margin-left: 800px;"
								class="b_maSel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
								role="button" aria-disabled="false">
								<span class="ui-button-text">查询</span>
							</button>
							<button onclick="add()" 
								style="margin-top: -50px;margin-left: 900px;"
								class="b_maSel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
								role="button" aria-disabled="false">
								<span class="ui-button-text">添加</span>
							</button>
							<div style="margin-top: 0px;">
								<table id="caipuinfo"></table>
								<div id="caipupage"></div>
							</div>
							<div id="caipu_del" style="display: none;" title="删除菜谱">
								您确定要将<span id="deltname"></span> 这条菜谱信息删除吗?
							</div>
						</div>
					</div>
				</div>
</body>
<script type="text/javascript">
	$("#tabs").tabs();

	function search(){	
		var gy_id = $('#gy_types  option:selected').val();
		var kw_id = $('#kw_types  option:selected').val();
		var nd_id = $('#nd_types  option:selected').val();
		var cx_id = $('#cx_types  option:selected').val();
		var cp_name = $('#cp_name').val();
		var cp_time = $('#cp_time').val();
		if(cp_time!=""&&!/^-?\d+(\.\d+)?$/.test(cp_time)){
			$().message("请输入正确时长");
			return
		}
		if(cp_time==""){
			cp_time = 0;
		}
		jQuery("#caipuinfo").jqGrid('setGridParam',{url:"${aier_url}${aier_urijs}caipu_search${aier_suffix}?gy_id="+gy_id+"&kw_id="+kw_id
			+"&nd_id="+nd_id+"&cx_id="+cx_id+"&cp_name="+cp_name+"&cp_time="+cp_time,page:1}).trigger("reloadGrid");
	}
	
	
	//$(".chosen").chosen();
	
	
	
	
</script>

</html>